; ModuleID = 'stack_buffer_overfklow.cc'
source_filename = "stack_buffer_overfklow.cc"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@__asan_option_detect_stack_use_after_return = external global i32
@__asan_gen_ = private unnamed_addr constant [26 x i8] c"1 32 400 13 stack_array:4\00", align 1
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @asan.module_ctor, i8* null }]

; Function Attrs: norecurse nounwind readnone sanitize_address uwtable
define i32 @main(i32 %argc, i8** nocapture readnone %argv) local_unnamed_addr #0 !dbg !7 {
  %asan_local_stack_base = alloca i64, !dbg !21
  %1 = load i32, i32* @__asan_option_detect_stack_use_after_return, !dbg !21
  %2 = icmp ne i32 %1, 0, !dbg !21
  br i1 %2, label %3, label %5

; <label>:3:                                      ; preds = %0
  %4 = call i64 @__asan_stack_malloc_3(i64 512), !dbg !21
  br label %5

; <label>:5:                                      ; preds = %0, %3
  %6 = phi i64 [ 0, %0 ], [ %4, %3 ], !dbg !21
  %7 = icmp eq i64 %6, 0, !dbg !21
  br i1 %7, label %8, label %10

; <label>:8:                                      ; preds = %5
  %MyAlloca = alloca i8, i64 512, align 32, !dbg !21
  %9 = ptrtoint i8* %MyAlloca to i64, !dbg !21
  br label %10

; <label>:10:                                     ; preds = %5, %8
  %11 = phi i64 [ %6, %5 ], [ %9, %8 ], !dbg !21
  store i64 %11, i64* %asan_local_stack_base, !dbg !21
  %12 = add i64 %11, 32, !dbg !21
  %13 = inttoptr i64 %12 to [100 x i32]*, !dbg !21
  %14 = inttoptr i64 %11 to i64*, !dbg !21
  store i64 1102416563, i64* %14, !dbg !21
  %15 = add i64 %11, 8, !dbg !21
  %16 = inttoptr i64 %15 to i64*, !dbg !21
  store i64 ptrtoint ([26 x i8]* @__asan_gen_ to i64), i64* %16, !dbg !21
  %17 = add i64 %11, 16, !dbg !21
  %18 = inttoptr i64 %17 to i64*, !dbg !21
  store i64 ptrtoint (i32 (i32, i8**)* @main to i64), i64* %18, !dbg !21
  %19 = lshr i64 %11, 3, !dbg !21
  %20 = add i64 %19, 2147450880, !dbg !21
  %21 = add i64 %20, 0, !dbg !21
  %22 = inttoptr i64 %21 to i64*, !dbg !21
  store i64 -506381209984437775, i64* %22, align 1, !dbg !21
  %23 = add i64 %20, 8, !dbg !21
  %24 = inttoptr i64 %23 to i64*, !dbg !21
  store i64 -506381209866536712, i64* %24, align 1, !dbg !21
  %25 = add i64 %20, 16, !dbg !21
  %26 = inttoptr i64 %25 to i64*, !dbg !21
  store i64 -506381209866536712, i64* %26, align 1, !dbg !21
  %27 = add i64 %20, 24, !dbg !21
  %28 = inttoptr i64 %27 to i64*, !dbg !21
  store i64 -506381209866536712, i64* %28, align 1, !dbg !21
  %29 = add i64 %20, 32, !dbg !21
  %30 = inttoptr i64 %29 to i64*, !dbg !21
  store i64 -506381209866536712, i64* %30, align 1, !dbg !21
  %31 = add i64 %20, 40, !dbg !21
  %32 = inttoptr i64 %31 to i64*, !dbg !21
  store i64 -506381209866536712, i64* %32, align 1, !dbg !21
  %33 = add i64 %20, 48, !dbg !21
  %34 = inttoptr i64 %33 to i64*, !dbg !21
  store i64 -868076554939729672, i64* %34, align 1, !dbg !21
  %35 = add i64 %20, 56, !dbg !21
  %36 = inttoptr i64 %35 to i64*, !dbg !21
  store i64 -868082074056920077, i64* %36, align 1, !dbg !21
  call void @llvm.dbg.declare(metadata i64* %asan_local_stack_base, metadata !17, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 32)), !dbg !22
  call void @llvm.dbg.value(metadata i32 %argc, metadata !15, metadata !DIExpression()), !dbg !23
  call void @llvm.dbg.value(metadata i8** %argv, metadata !16, metadata !DIExpression()), !dbg !24
  %37 = bitcast [100 x i32]* %13 to i8*, !dbg !25
  %38 = add i64 %20, 4, !dbg !25
  %39 = inttoptr i64 %38 to i64*, !dbg !25
  store i64 0, i64* %39, align 1, !dbg !25
  %40 = add i64 %20, 12, !dbg !25
  %41 = inttoptr i64 %40 to i64*, !dbg !25
  store i64 0, i64* %41, align 1, !dbg !25
  %42 = add i64 %20, 20, !dbg !25
  %43 = inttoptr i64 %42 to i64*, !dbg !25
  store i64 0, i64* %43, align 1, !dbg !25
  %44 = add i64 %20, 28, !dbg !25
  %45 = inttoptr i64 %44 to i64*, !dbg !25
  store i64 0, i64* %45, align 1, !dbg !25
  %46 = add i64 %20, 36, !dbg !25
  %47 = inttoptr i64 %46 to i64*, !dbg !25
  store i64 0, i64* %47, align 1, !dbg !25
  %48 = add i64 %20, 44, !dbg !25
  %49 = inttoptr i64 %48 to i64*, !dbg !25
  store i64 0, i64* %49, align 1, !dbg !25
  %50 = add i64 %20, 52, !dbg !25
  %51 = inttoptr i64 %50 to i16*, !dbg !25
  store i16 0, i16* %51, align 1, !dbg !25
  call void @llvm.lifetime.start.p0i8(i64 400, i8* nonnull %37) #3, !dbg !25
  %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* %13, i64 0, i64 1, !dbg !26
  %52 = ptrtoint i32* %arrayidx to i64, !dbg !27
  %53 = lshr i64 %52, 3, !dbg !27
  %54 = add i64 %53, 2147450880, !dbg !27
  %55 = inttoptr i64 %54 to i8*, !dbg !27
  %56 = load i8, i8* %55, !dbg !27
  %57 = icmp ne i8 %56, 0, !dbg !27
  br i1 %57, label %58, label %64, !dbg !27, !prof !28

; <label>:58:                                     ; preds = %10
  %59 = and i64 %52, 7, !dbg !27
  %60 = add i64 %59, 3, !dbg !27
  %61 = trunc i64 %60 to i8, !dbg !27
  %62 = icmp sge i8 %61, %56, !dbg !27
  br i1 %62, label %63, label %64, !dbg !27

; <label>:63:                                     ; preds = %58
  call void @__asan_report_store4(i64 %52), !dbg !27
  call void asm sideeffect "", ""()
  unreachable

; <label>:64:                                     ; preds = %58, %10
  store i32 0, i32* %arrayidx, align 4, !dbg !27, !tbaa !29
  %add = add nsw i32 %argc, 103, !dbg !33
  %idxprom = sext i32 %add to i64, !dbg !34
  %arrayidx1 = getelementptr inbounds [100 x i32], [100 x i32]* %13, i64 0, i64 %idxprom, !dbg !34
  %65 = ptrtoint i32* %arrayidx1 to i64, !dbg !34
  %66 = lshr i64 %65, 3, !dbg !34
  %67 = add i64 %66, 2147450880, !dbg !34
  %68 = inttoptr i64 %67 to i8*, !dbg !34
  %69 = load i8, i8* %68, !dbg !34
  %70 = icmp ne i8 %69, 0, !dbg !34
  br i1 %70, label %71, label %77, !dbg !34, !prof !28

; <label>:71:                                     ; preds = %64
  %72 = and i64 %65, 7, !dbg !34
  %73 = add i64 %72, 3, !dbg !34
  %74 = trunc i64 %73 to i8, !dbg !34
  %75 = icmp sge i8 %74, %69, !dbg !34
  br i1 %75, label %76, label %77, !dbg !34

; <label>:76:                                     ; preds = %71
  call void @__asan_report_load4(i64 %65), !dbg !34
  call void asm sideeffect "", ""()
  unreachable

; <label>:77:                                     ; preds = %71, %64
  %78 = load i32, i32* %arrayidx1, align 4, !dbg !34, !tbaa !29
  %79 = add i64 %20, 4, !dbg !35
  %80 = inttoptr i64 %79 to i64*, !dbg !35
  store i64 -506381209866536712, i64* %80, align 1, !dbg !35
  %81 = add i64 %20, 12, !dbg !35
  %82 = inttoptr i64 %81 to i64*, !dbg !35
  store i64 -506381209866536712, i64* %82, align 1, !dbg !35
  %83 = add i64 %20, 20, !dbg !35
  %84 = inttoptr i64 %83 to i64*, !dbg !35
  store i64 -506381209866536712, i64* %84, align 1, !dbg !35
  %85 = add i64 %20, 28, !dbg !35
  %86 = inttoptr i64 %85 to i64*, !dbg !35
  store i64 -506381209866536712, i64* %86, align 1, !dbg !35
  %87 = add i64 %20, 36, !dbg !35
  %88 = inttoptr i64 %87 to i64*, !dbg !35
  store i64 -506381209866536712, i64* %88, align 1, !dbg !35
  %89 = add i64 %20, 44, !dbg !35
  %90 = inttoptr i64 %89 to i64*, !dbg !35
  store i64 -506381209866536712, i64* %90, align 1, !dbg !35
  %91 = add i64 %20, 52, !dbg !35
  %92 = inttoptr i64 %91 to i16*, !dbg !35
  store i16 -1800, i16* %92, align 1, !dbg !35
  call void @llvm.lifetime.end.p0i8(i64 400, i8* nonnull %37) #3, !dbg !35
  store i64 1172321806, i64* %14, !dbg !36
  %93 = icmp ne i64 %6, 0, !dbg !36
  br i1 %93, label %94, label %100, !dbg !36

; <label>:94:                                     ; preds = %77
  %95 = add i64 %20, 0, !dbg !36
  call void @__asan_set_shadow_f5(i64 %95, i64 64), !dbg !36
  %96 = add i64 %6, 504, !dbg !36
  %97 = inttoptr i64 %96 to i64*, !dbg !36
  %98 = load i64, i64* %97, !dbg !36
  %99 = inttoptr i64 %98 to i8*, !dbg !36
  store i8 0, i8* %99, !dbg !36
  br label %102, !dbg !36

; <label>:100:                                    ; preds = %77
  %101 = add i64 %20, 0, !dbg !36
  call void @__asan_set_shadow_00(i64 %101, i64 64), !dbg !36
  br label %102, !dbg !36

; <label>:102:                                    ; preds = %100, %94
  ret i32 %78, !dbg !36
}

; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1

; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2

; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2

; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.value(metadata, metadata, metadata) #1

declare void @__asan_report_load_n(i64, i64)

declare void @__asan_loadN(i64, i64)

declare void @__asan_report_load1(i64)

declare void @__asan_load1(i64)

declare void @__asan_report_load2(i64)

declare void @__asan_load2(i64)

declare void @__asan_report_load4(i64)

declare void @__asan_load4(i64)

declare void @__asan_report_load8(i64)

declare void @__asan_load8(i64)

declare void @__asan_report_load16(i64)

declare void @__asan_load16(i64)

declare void @__asan_report_store_n(i64, i64)

declare void @__asan_storeN(i64, i64)

declare void @__asan_report_store1(i64)

declare void @__asan_store1(i64)

declare void @__asan_report_store2(i64)

declare void @__asan_store2(i64)

declare void @__asan_report_store4(i64)

declare void @__asan_store4(i64)

declare void @__asan_report_store8(i64)

declare void @__asan_store8(i64)

declare void @__asan_report_store16(i64)

declare void @__asan_store16(i64)

declare void @__asan_report_exp_load_n(i64, i64, i32)

declare void @__asan_exp_loadN(i64, i64, i32)

declare void @__asan_report_exp_load1(i64, i32)

declare void @__asan_exp_load1(i64, i32)

declare void @__asan_report_exp_load2(i64, i32)

declare void @__asan_exp_load2(i64, i32)

declare void @__asan_report_exp_load4(i64, i32)

declare void @__asan_exp_load4(i64, i32)

declare void @__asan_report_exp_load8(i64, i32)

declare void @__asan_exp_load8(i64, i32)

declare void @__asan_report_exp_load16(i64, i32)

declare void @__asan_exp_load16(i64, i32)

declare void @__asan_report_exp_store_n(i64, i64, i32)

declare void @__asan_exp_storeN(i64, i64, i32)

declare void @__asan_report_exp_store1(i64, i32)

declare void @__asan_exp_store1(i64, i32)

declare void @__asan_report_exp_store2(i64, i32)

declare void @__asan_exp_store2(i64, i32)

declare void @__asan_report_exp_store4(i64, i32)

declare void @__asan_exp_store4(i64, i32)

declare void @__asan_report_exp_store8(i64, i32)

declare void @__asan_exp_store8(i64, i32)

declare void @__asan_report_exp_store16(i64, i32)

declare void @__asan_exp_store16(i64, i32)

declare i8* @__asan_memmove(i8*, i8*, i64)

declare i8* @__asan_memcpy(i8*, i8*, i64)

declare i8* @__asan_memset(i8*, i32, i64)

declare void @__asan_handle_no_return()

declare void @__sanitizer_ptr_cmp(i64, i64)

declare void @__sanitizer_ptr_sub(i64, i64)

declare i64 @__asan_stack_malloc_0(i64)

declare void @__asan_stack_free_0(i64, i64)

declare i64 @__asan_stack_malloc_1(i64)

declare void @__asan_stack_free_1(i64, i64)

declare i64 @__asan_stack_malloc_2(i64)

declare void @__asan_stack_free_2(i64, i64)

declare i64 @__asan_stack_malloc_3(i64)

declare void @__asan_stack_free_3(i64, i64)

declare i64 @__asan_stack_malloc_4(i64)

declare void @__asan_stack_free_4(i64, i64)

declare i64 @__asan_stack_malloc_5(i64)

declare void @__asan_stack_free_5(i64, i64)

declare i64 @__asan_stack_malloc_6(i64)

declare void @__asan_stack_free_6(i64, i64)

declare i64 @__asan_stack_malloc_7(i64)

declare void @__asan_stack_free_7(i64, i64)

declare i64 @__asan_stack_malloc_8(i64)

declare void @__asan_stack_free_8(i64, i64)

declare i64 @__asan_stack_malloc_9(i64)

declare void @__asan_stack_free_9(i64, i64)

declare i64 @__asan_stack_malloc_10(i64)

declare void @__asan_stack_free_10(i64, i64)

declare void @__asan_poison_stack_memory(i64, i64)

declare void @__asan_unpoison_stack_memory(i64, i64)

declare void @__asan_set_shadow_00(i64, i64)

declare void @__asan_set_shadow_f1(i64, i64)

declare void @__asan_set_shadow_f2(i64, i64)

declare void @__asan_set_shadow_f3(i64, i64)

declare void @__asan_set_shadow_f5(i64, i64)

declare void @__asan_set_shadow_f8(i64, i64)

declare void @__asan_alloca_poison(i64, i64)

declare void @__asan_allocas_unpoison(i64, i64)

declare void @__asan_before_dynamic_init(i64)

declare void @__asan_after_dynamic_init()

declare void @__asan_register_globals(i64, i64)

declare void @__asan_unregister_globals(i64, i64)

declare void @__asan_register_image_globals(i64)

declare void @__asan_unregister_image_globals(i64)

declare void @__asan_register_elf_globals(i64, i64, i64)

declare void @__asan_unregister_elf_globals(i64, i64, i64)

declare void @__asan_init()

define internal void @asan.module_ctor() {
  call void @__asan_init()
  call void @__asan_version_mismatch_check_v8()
  ret void
}

declare void @__asan_version_mismatch_check_v8()

attributes #0 = { norecurse nounwind readnone sanitize_address uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone speculatable }
attributes #2 = { argmemonly nounwind }
attributes #3 = { nounwind }

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "stack_buffer_overfklow.cc", directory: "/home/vagrant/proj/rust/mycode/rust_test/c")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)"}
!7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !14)
!8 = !DISubroutineType(types: !9)
!9 = !{!10, !10, !11}
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
!13 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
!14 = !{!15, !16, !17}
!15 = !DILocalVariable(name: "argc", arg: 1, scope: !7, file: !1, line: 2, type: !10)
!16 = !DILocalVariable(name: "argv", arg: 2, scope: !7, file: !1, line: 2, type: !11)
!17 = !DILocalVariable(name: "stack_array", scope: !7, file: !1, line: 4, type: !18)
!18 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 3200, elements: !19)
!19 = !{!20}
!20 = !DISubrange(count: 100)
!21 = !DILocation(line: 2, scope: !7)
!22 = !DILocation(line: 4, column: 7, scope: !7)
!23 = !DILocation(line: 2, column: 14, scope: !7)
!24 = !DILocation(line: 2, column: 27, scope: !7)
!25 = !DILocation(line: 4, column: 3, scope: !7)
!26 = !DILocation(line: 5, column: 3, scope: !7)
!27 = !DILocation(line: 5, column: 18, scope: !7)
!28 = !{!"branch_weights", i32 1, i32 100000}
!29 = !{!30, !30, i64 0}
!30 = !{!"int", !31, i64 0}
!31 = !{!"omnipotent char", !32, i64 0}
!32 = !{!"Simple C++ TBAA"}
!33 = !DILocation(line: 6, column: 27, scope: !7)
!34 = !DILocation(line: 6, column: 10, scope: !7)
!35 = !DILocation(line: 7, column: 1, scope: !7)
!36 = !DILocation(line: 6, column: 3, scope: !7)
